Introduction to programming in assembler with Pasmo: Compiling and testing a "Hello World" Pincha aquí para verlo en español Pasmo is a Z80 cross assembler, written in standard C++ that compiles easily in multiple platforms. Actually can generate object code in the following formats: raw binary, Intel HEX, PRL for CP/M Plus RSX, Plus3Dos (Spectrum +3 disk), TAP, TZX and CDT (Spectrum and Amstrad CPC emulators tape images), AmsDos (Amstrad CPC disk) and MSX (for use with BLOAD from disk in Basic). It can be downloaded from the official website. Not require any type of installation is a single executable, which we have to put in some folder that is in the path or directly in the folder where we will compile. With any text or code editor (with notepad in Windows) generate a file called Pasmo01.asm with the following contents (at the end of the tutorial can be downloaded all in one zip):: org #6000 TXT_OUTPUT EQU #BB5A KM_WAIT_CHAR EQU #BB06 LD A, 'H' CALL TXT_OUTPUT LD A, 'e' CALL TXT_OUTPUT LD A, 'l' CALL TXT_OUTPUT LD A, 'l' CALL TXT_OUTPUT LD A, 'o' CALL TXT_OUTPUT LD A, ' ' CALL TXT_OUTPUT LD A, 'w' CALL TXT_OUTPUT LD A, 'o' CALL TXT_OUTPUT LD A, 'r' CALL TXT_OUTPUT LD A, 'l' CALL TXT_OUTPUT LD A, 'd' CALL TXT_OUTPUT CALL KM_WAIT_CHAR RET A simple little program that uses the firmware TXT_OUTPUT. We have to compile it as follows: pasmo Pasmo01.asm Pasmo01.bin If all goes well, we have generated a new file Pasmo01.bin, which can run on the Amstrad CPC. For testing, we will load the generated binary in an emulator, for this we must create a file dsk (disk image) with the binary that we compiled in order to load / run in the emulator. For this we use for example ManageDSK or CPCDiskXP. To generate a dsk with CPCDiskXP, we execute the program, then we press in "Dsk Editor", then we press in "New" select the default format "CPC Data" and then we press Ok. Now click "Add Files" to add our binary, look for the directory where we compiled and select the file Pasmo01.bin, now CPCDiskXP will ask if you want to add the Amsdos header, press Yes and let the values displayed by default and click Ok. Now we press the button "Save" to store our Dsk, I have called it "Pasmo01.dsk" in the same directory. With the latest version of CPCDiskXP, we can generate a dsk from the command line (or bat) as follows: CPCDiskXP -File Pasmo01.bin -AddAmsdosHeader 6000 -AddToNewDsk Pasmo01.dsk We load the dsk our favorite emulator (I usually use CPCE and Winape) and execute it using run"pasmo01 and you should see the following: |
You can download a zip file with all the files here: Introduction_ to_programming_in_assembler_with_Pasmo_Compiling_and_testing_a_Hello_World.zip |
www.CPCMania.com 2012 |